﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StyleMVVM.DependencyInjection;
using StyleMVVM.View;
using StyleMVVM.ViewModel;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace ExampleApp.ViewModels
{
	public class CommandsAndEventsViewModel : BaseViewModel
	{
		private DelegateCommand enableCommand;
		private DelegateCommand disableCommand;
		private bool enabled = false;
		
		public DelegateCommand EnableCommand
		{
			get
			{
				if(enableCommand == null)
				{
					enableCommand = new DelegateCommand(x =>
						                                    {
							                                    enabled = true; 
																			DisableCommand.RaiseCanExecuteChanged();
						                                    });
				}

				return enableCommand;
			}
		}

		public DelegateCommand DisableCommand
		{
			get
			{
				if(disableCommand == null)
				{
					disableCommand = new DelegateCommand(x =>
						                                 {
							                                 enabled = false; 
																		DisableCommand.RaiseCanExecuteChanged();
						                                 },
																	x => enabled);
				}
				return disableCommand;
			}
		}

		[Import]
		public IMessageBoxService MessageBoxService { get; set; }

		public void ItemClicked(FrameworkElement element,ItemClickEventArgs eventArgs)
		{
			MessageBoxService.Show("You clicked: " + eventArgs.ClickedItem);
		}
	}
}
